﻿CREATE TABLE [dbo].[Steps] (
    [StepID]            INT            IDENTITY (1, 1) NOT NULL,
    [StepName]          NVARCHAR (MAX) NULL,
    [AssignTo]          NVARCHAR (MAX) NULL,
    [StepOrder]         INT            NOT NULL,
    [ChildProcessType]  INT            NOT NULL,
    [ProcessVersionID]  INT            NOT NULL,
    [ParentStepID]      INT            NULL,
    [ParentStep_StepID] INT            NULL,
    [Type]              NVARCHAR (MAX) NULL,
    [TypeData]          NVARCHAR (MAX) NULL,
    [WorkbasketFormID]  INT            DEFAULT ((0)) NOT NULL,
    [SLA]               INT            DEFAULT ((0)) NOT NULL,
    [IsPublic]          BIT            DEFAULT ((0)) NOT NULL,
    CONSTRAINT [PK_dbo.Steps] PRIMARY KEY CLUSTERED ([StepID] ASC),
    CONSTRAINT [FK_dbo.Steps_dbo.Steps_ParentStep_StepID] FOREIGN KEY ([ParentStep_StepID]) REFERENCES [dbo].[Steps] ([StepID])
);


GO
CREATE NONCLUSTERED INDEX [IX_ProcessVersionID]
    ON [dbo].[Steps]([ProcessVersionID] ASC);


GO
CREATE NONCLUSTERED INDEX [IX_ParentStep_StepID]
    ON [dbo].[Steps]([ParentStep_StepID] ASC);

